      character*134 line
      character*11 idg
      real*4 temp
      integer itemp(12)

      open(1,form='formatted',file='ID_US_G')
      open(2,form='formatted',file='hcn_doe_mean_data_fil')
      open(10,form='formatted',file='USHCN.v2.mean_noFIL')

      do mfil=0,0 ! ,1 0: fill-ins skipped; 1: fill-ins used
      rewind 1
      rewind 2
      nout=10+mfil
      read(1,'(5x,i6,1x,a11,1x,i1)') idus,idg,iz
   10 read(2,'(a)',end=100) line
      read(line(1:6),*) idus0

c**** check whether us-id is still ok
      do while (idus0.ne.idus)
         read(1,'(5x,i6,1x,a11,1x,i1)',end=200) idus,idg,iz
      end do

      itemp=-9999
      read(line(8:11),*) iyear
      if(line(13:14).ne.'3A') stop 'should not happen'
      do m=1,12
        indd=15+(m-1)*10 ! start of data
        indf=indd+9      ! position of fillin flag
        if(mfil==0.and.line(indf:indf)=='M') cycle
        read(line(indd:indd+4),'(f5.2)') temp
        if(temp.gt.-99.00) itemp(m)=nint( 50.*(temp-32.)/9 ) ! F->.1C
      end do

      write(nout,'(a11,i1,i4,12i5)') idg,iz,iyear,itemp
      go to 10

  100 continue
      end do
      stop
  200 write(*,*) 'id-file ended !'
      stop
      end
